package com.wei.miaosha.service;

import com.wei.miaosha.dao.GoodsDao;
import com.wei.miaosha.domain.MiaoshaGoods;
import com.wei.miaosha.domain.MiaoshaOrder;
import com.wei.miaosha.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Weizichen on 2018/8/18.
 * desc:商品业务层
 */
@Service
public class GoodsService {
    @Autowired
    GoodsDao goodsDao;


    public List<GoodsVo> listGoodsVo() {
        return goodsDao.ListGoodsVo();
    }

    public GoodsVo getGoodsVoByGoodsId(long goodsId) {
        return goodsDao.getGoodsVoByGoodsId(goodsId);
    }

    public boolean reduceStock(GoodsVo goods) {
        MiaoshaGoods miaoshaGoods = new MiaoshaGoods();
        miaoshaGoods.setGoodsId(goods.getId());
        int ret = goodsDao.reduceStock(miaoshaGoods);
        return ret > 0;
    }


}
